<?php
/**
 * Post dispute form.
 *
 * @category Zend
 * @package Form
 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc.
 * @version $Id$
 * @link http://framework.zend.com
 * @since Available since release 1.0
 * @license GPL v3
 */

class Application_Form_Post extends Twitter_Form
{
    /**
     * Setup form elements
     */
    public function init()
    {   
        $this->setAttrib('horizontal', true);
        $this->setAttrib('id', 'post');
        
        $this->addElement('text', 'title', array(
            'label' => 'Title',
            'description' => 'A title describing your post.',
            'required' => true,
            'validators' => array(
                array(
                    'validator' => 'NotEmpty',
                    'options' => array(
                        'messages' => array(
                            'isEmpty' => 'Please provide a title for your post.'
                        )
                    )
                )
            )
        ));
        
        $this->addElement('textarea', 'argument', array(
            'label' => 'Argument',
            'description' => 'Make the point you want to debate.',
            'required' => true,
            'cols' => 1,
            'rows' => 1,
            'validators' => array(
                array(
                    'validator' => 'NotEmpty',
                    'options' => array(
                        'messages' => array(
                            'isEmpty' => 'Enter your argument.'
                        )
                    )
                )
            )
        ));
        
        $categories = Disputeo_Cache::classCache('Application_Model_Category')->getList();
        
        $this->addElement('select', 'postcat', array(
            'label' => 'Category',
            'description' => 'What category does this post relate to?',
            'required' => true,
            'multiOptions' => array_merge(array(0 => 'Select a category'), $categories),
            'validators' => array(
                array(
                    'validator' => 'InArray',
                    'options' => array(
                        array_keys($categories),
                        'messages' => array(
                            'notInArray' => 'Please choose a category for your post.'
                        )
                    )
                )
            )
        ));
        
        $this->addElement('submit', 'post', array(
            'label' => 'Post',
            'class' => 'btn btn-success btn-large'
        ));
    }
}